﻿<script id="messageTmpl" type="text/x-jquery-tmpl">
    <div class="itemWrapper">
        <div class="head-subject">
            <button type="button" id="menuActionBack" class="header-back-link button gray"><span></span></button>
            <div class="importance pull-left">
                <i class="icon-{{if $item.important==false}}un{{/if}}important" 
                    title="{{if $item.important}}${ASC.Mail.Resources.MailScriptResource.ImportantLabel}{{else}}${ASC.Mail.Resources.MailScriptResource.NotImportantLabel}{{/if}}"></i>
            </div>
            {{if ASC.Mail.Constants.CRM_AVAILABLE == true}}
                <div class="header-crm-link pull-left" {{if $item.hasLinked == false}}style="display: none;"{{/if}}>
                    <i class="icon-crm-linked"></i>
                </div>
            {{/if}}
            <div class="viewTitle" {{if $item.last_message.subject !== undefined && $item.last_message.subject !== null && $item.last_message.subject !== ''}}title="${$item.last_message.subject}"{{/if}}>
                {{if typeof($item.last_message.subject)==='undefined' || $item.last_message.subject == null || $item.last_message.subject ==''}}
                    ${ASC.Mail.Resources.MailResource.NoSubject}
                {{else}}
                    ${$item.last_message.subject}
                {{/if}}
                {{if ASC.Mail.Constants.CRM_AVAILABLE == true}}
                <div class="header-crm-link" style="display: none"></div>
                {{/if}}
            </div>
        </div>

        {{if $item.messages.length == 1}}
            {{tmpl($item.messages[0], {
                fileSizeToStr   : $item.fileSizeToStr,
                cutFileName: $item.cutFileName,
                getFileNameWithoutExt: $item.getFileNameWithoutExt,
                getFileExtension: $item.getFileExtension,
                htmlEncode      : $item.htmlEncode,
                isSingleMessage         : true,
                folder                  : $item.folder
           }) $item.messages[0].template_name}}
        {{else}}
            {{tmpl({}, {
                needBottomBorder : false,
                needSortButton   : true,
                folder           : $item.folder
           }) "messageTopButtons"}}

            {{each $item.messages}}
                {{if $value.hidden_count > 0}}
                    {{tmpl($value, {
                        count       : $value.hidden_count
                   }) "collapsedMessagesTmpl"}}
                {{/if}}
                {{tmpl($value, {
                    fileSizeToStr   : $item.fileSizeToStr,
                    cutFileName: $item.cutFileName,
                    getFileNameWithoutExt: $item.getFileNameWithoutExt,
                    getFileExtension: $item.getFileExtension,
                    htmlEncode      : $item.htmlEncode,
                    isSingleMessage : false
               }) $value.template_name}}
            {{/each}}
        {{/if}}
    </div>
</script>

<script id="collapsedMessagesTmpl" type="text/x-jquery-tmpl">
    <div class="collapsed-messages" style="border-top: 1px solid #D7D8DC;">
        <label>${$item.count} ${ASC.Mail.Resources.MailResource.MoreLabel}</label>
    </div>
</script>

<script id="messageShortTmpl" type="text/x-jquery-tmpl">
    <div class="message-wrap{{if visible != true}} hidden{{/if}}" message_id="${id}" folder="${folder}" restore_folder_id="${restoreFolderId}" date="${date}">
        <table class="short-view{{if visible == true && wasNew == true}} new{{/if}}" message_id="${id}">
            <tbody>
                <tr class="message_short" data_id="${id}">
                    <td class="from_label">
                        <span>${ASC.Mail.Resources.MailScriptResource.FromLabel}:</span>
                    </td>
                    <td class="from">
                        <span title="${fromName}">${fromName}</span>
                    </td>
                    <td class="content">
                        <span title="${$item.htmlEncode(introduction)}">${$item.htmlEncode(introduction)}</span>
                    </td>
                    <td class="load_box">
                        <div class="loader hidden"></div>
                    </td>
                    <td class="icon">
                        {{if attachments.length > 0}}
                            <i class="{{if !calendarUid }}icon-attachment{{else}}icon-calendar{{/if}}"></i>
                        {{/if}}
                    </td>
                    <td class="date-time">
                        <span>
                            {{if isToday}}
                                ${ASC.Mail.Resources.MailResource.TodayLabel}
                            {{else}}
                                {{if isYesterday}}
                                    ${ASC.Mail.Resources.MailResource.YesterdayLabel}
                                {{else}}
                                    ${displayDate}
                                {{/if}}
                            {{/if}}
                        </span>
                    </td>
                    <td class="time">
                        <span>${displayTime}</span>
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="full-view hidden" message_id="${id}" content_blocked="${contentIsBlocked}" is_crm="true" is_personal="true" is_single="false">
            {{if $item.isSingleMessage == true}}
                {{tmpl($item.data, {
                    needBottomBorder : true,
                    needSortButton   : false,
                    folder           : $item.folder
               }) "messageTopButtons"}}
            {{/if}}
            <div class="head with-entity-menu" message_id="${id}">
                <table>
                    <tbody>
                        <tr class="row" data_id="${id}">
                            <td class="header-label">
                                ${ASC.Mail.Resources.MailScriptResource.FromLabel}:
                            </td>
                            <td class="header-value">
                                <div class="value">
                                    <a class="from" href="javascript:void(0);">${from}</a>
                                    <span style="display:none; margin-left: 16px;" class="red-text from-disabled-warning">
                                        ${ASC.Mail.Resources.MailResource.MessageFromWarning}&nbsp;
                                        <a class="link dotline red-text" onclick="javascript:accountsModal.activateAccount('${address}', true);">${ASC.Mail.Resources.MailResource.ActivateAccountLabel}</a>
                                    </span>
                                </div>
                            </td>
                            <td class="header-menu">
                                <div class="entity-menu" data_id="${id}" title="${ASC.Mail.Resources.MailScriptResource.Actions}"></div>
                            </td>
                        </tr>
                        <tr class="row" data_id="${id}">
                            <td class="header-label">
                                ${ASC.Mail.Resources.MailScriptResource.ToLabel}:
                            </td>
                            <td class="header-value">
                                <div class="value to-addresses">${to}</div>
                            </td>
                        </tr>
                        {{if cc}}
                            <tr class="row" data_id="${id}">
                                <td class="header-label">
                                    ${ASC.Mail.Resources.MailResource.CopyLabel}:
                                </td>
                                <td class="header-value">
                                    <div class="value cc-addresses">${cc}</div>
                                </td>
                            </tr>
                        {{/if}}
                        {{if bcc}}
                            <tr class="row" data_id="${id}">
                                <td class="header-label">
                                    ${ASC.Mail.Resources.MailResource.BCCLabel}:
                                </td>
                                <td class="header-value">
                                    <div class="value bcc-addresses">${bcc}</div>
                                </td>
                            </tr>
                        {{/if}}
                        <tr class="row" data_id="${id}">
                            <td class="header-label">
                                ${ASC.Mail.Resources.MailScriptResource.DateLabel}:
                            </td>
                            <td class="header-value" colspan="2">
                                <div class="value">
                                    <span>${displayDate}</span>
                                    <span style="margin-left: 5px">${displayTime}</span>
                                </div>
                            </td>
                        </tr>
                        <tr class="row tags hidden" data_id="${id}">
                            <td class="header-label">
                                ${ASC.Mail.Resources.MailScriptResource.Tags}:
                            </td>
                            <td class="header-value" colspan="2">
                                <div class="value"><div class="itemTags"></div></div>
                            </td>
                        </tr>
                        <tr class="row calendar hidden">
                            <td class="header-label">
                                ${ASC.Mail.Resources.MailScriptResource.CalendarLabel}:
                            </td>
                            <td class="header-value" colspan="2">
                                <div class="value error" style="display: none;">
                                    <span style="color:#cc0000;">${ASC.Mail.Resources.MailScriptResource.ErrorUnsupportedFileFormat}</span>
                                </div>
                                <div class="value loader-fx" style="padding-top: 3px;">
                                    <div class="loader-middle"></div>
                                    <div class="loader-middle-lable">${ASC.Mail.Resources.MailResource.LoadingLabel}</div>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>

            {{if contentIsBlocked == true}}
                {{tmpl($item.data, {}) "messageBlockContent"}}
            {{/if}}

            <div message_id="${id}" class="body"></div>

            {{if hasAttachments == true}}
                <div class="attachments" message_id="${id}">
                    {{if attachments.length > 0}}
                        <div class="title-attachments">
                            <div class="icon"><i class="icon-attachment"></i></div>
                            <div class="attachment-message has-attachment"></div>${ASC.Mail.Resources.MailResource.Attachments} (${attachments.length}):
                            <span class="fullSizeLabel">
                                ${ASC.Mail.Resources.MailResource.FullSize}: ${$item.fileSizeToStr(full_size)}
                            </span>
                        </div>
                         {{if ASC.Mail.Master.IsTurnOnAttachmentsGroupOperations == true}}
                                {{if attachments.length > 1}}
                                    <div class="attachments-buttons">
                                        <i class="icon-download-all" />
                                        <a href="${download_all_url}" target="_blank" class="baseLinkAction link dotline">${ASC.Mail.Resources.MailResource.AttachDownloadAll}</a>
                                        <i class="icon-save-all-to-teamlab" />
                                        <a href="javascript:void(0);" class="exportAttachemntsToMyDocs baseLinkAction link dotline">${ASC.Mail.Resources.MailResource.ExportAttachmentsToMyDocuments}</a>
                                    </div>
                                {{/if}}
                        {{/if}}
                    {{/if}}
                    <table class="attachments_list" 
                        save_to_docs_attachment="${ASC.Mail.Resources.MailResource.SaveAttachToMyDocs}"
                        save_to_projects_docs_attachment="${ASC.Mail.Resources.MailResource.SaveAttachToProjDocs}"
                        attach_to_crm_attachment="${ASC.Mail.Resources.MailResource.AttacToCRMContact}">
                        <tbody>
                            {{each attachments}}
                                <tr class="row with-entity-menu" data_id="${$value.fileId}">
                                    <td class="file_icon">
                                        <div class="attachmentImage ${$value.iconCls}"/>
                                    </td>
                                    <td class="file_info">
                                        <a {{if $value.handlerUrl.slice(0, 11) !== 'javascript:'}}target="_blank"{{/if}} href="${$value.handlerUrl}" title="${$value.fileName}" 
                                            {{if $value.isImage == true}}
                                                class="screenzoom" 
                                            {{else}} 
                                                {{if $value.isMedia == true}}
                                                    class="mediafile"
                                                {{else}}
                                                    {{if $value.canView == false}} download="${$value.fileName}" {{/if}} 
                                                {{/if}}
                                            {{/if}}>
                                            <span class="file-name">
                                                ${$item.cutFileName($item.getFileNameWithoutExt($value.fileName))}
                                                <span class="file-extension">${$item.getFileExtension($value.fileName)}</span>
                                            </span>
                                        </a>
                                        <span class="fullSizeLabel">(${$item.fileSizeToStr($value.size)})</span>
                                        {{if $value.canEdit == true}}
                                            <div class="icon_edit">
                                                <div class="pencil" title="${ASC.Mail.Resources.MailResource.EditAttachment}" onclick="messagePage.editDocumentAttachment(${$value.fileId});"/>
                                            </div>
                                        {{/if}}
                                    </td>
                                    <td class="menu_column">
                                        <div class="entity-menu" data_id="${$value.fileId}" name="${$value.fileName}" title="${ASC.Mail.Resources.MailScriptResource.Actions}" />
                                    </td>
                                </tr>
                            {{/each}}
                        </tbody>
                    </table>
                </div>
            {{/if}}
        </div>
    </div>
</script>

<script id="messageBlockContent" type="text/x-jquery-tmpl">
    <div id="id_block_content_popup_${id}" class="error-popup hidden">
            <span class="text">${ASC.Mail.Resources.MailResource.BlockedContentWarning}</span>
            <a id="id-btn-block-content-${id}" class="link dotline" href="#" onclick="return false;">${ASC.Mail.Resources.MailResource.DisplayImagesLabel}</a>
            <a id="id-btn-always-block-content-${id}" class="link dotline" href="#" onclick="return false;" style="margin-left: 8px;">${ASC.Mail.Resources.MailResource.AlwaysDisplayImagesLabel} "${sender_address}"</a>
            <a class="close-info-popup" href="#" onclick="jq('#id_block_content_popup_${id}').hide(); return false;">&times;</a>
    </div>
</script>

<script id="messageTopButtons" type="text/x-jquery-tmpl">
    <div class="messageHeader" {{if $item.needBottomBorder== false}}style="border-bottom:none;"{{/if}}>
        <div class="contentMenuWrapper">
            <ul class="clearFix contentMenu contentMenuDisplayAll" id="MessageGroupButtons">
                {{if $item.folder != 4 && $item.folder != 5 }}
                <li class="menuAction btnReply unlockAction">
                    <span title="${ASC.Mail.Resources.MailResource.ReplyBtnLabel}">${ASC.Mail.Resources.MailResource.ReplyBtnLabel}</span>
                </li>
                <li class="menuAction btnReplyAll unlockAction">
                    <span title="${ASC.Mail.Resources.MailResource.ReplyAllBtnLabel}">${ASC.Mail.Resources.MailResource.ReplyAllBtnLabel}</span>
                </li>
                <li class="menuAction btnForward unlockAction">
                    <span title="${ASC.Mail.Resources.MailResource.ForwardLabel}">${ASC.Mail.Resources.MailResource.ForwardLabel}</span>
                </li>
                {{/if}}
                <li class="menuAction btnDelete unlockAction">
                    {{if $item.folder == 4 || $item.folder == 5 }}
                    <span title="${ASC.Mail.Resources.MailScriptResource.FilterActionDeleteLabel}">${ASC.Mail.Resources.MailScriptResource.FilterActionDeleteLabel}</span>
                    {{else}}
                    <span title="${ASC.Mail.Resources.MailResource.DeleteBtnLabel}">${ASC.Mail.Resources.MailResource.DeleteBtnLabel}</span>
                    {{/if}}
                </li>
                {{if $item.folder != 4 && $item.folder != 5 }}
                {{if $item.folder == 1 || $item.folder == 6 }}
                <li class="menuAction btnSpam unlockAction">
                    <span title="${ASC.Mail.Resources.MailScriptResource.SpamLabel}">${ASC.Mail.Resources.MailScriptResource.SpamLabel}</span>
                </li>
                {{/if}}
                <li class="menuAction btnAddTag unlockAction">
                    <span title="${ASC.Mail.Resources.MailResource.AddTag}">${ASC.Mail.Resources.MailResource.AddTag}</span>
                    <div class="down_arrow"></div>
                </li>
                {{else}}
                {{if $item.folder == 4 }}
                <li class="menuAction btnRestore unlockAction">
                    <span title="${ASC.Mail.Resources.MailScriptResource.RestoreBtnLabel}">${ASC.Mail.Resources.MailScriptResource.RestoreBtnLabel}</span>
                </li>
                {{else}}
                <li class="menuAction btnNotSpam unlockAction">
                    <span title="${ASC.Mail.Resources.MailScriptResource.NotSpamLabel}">${ASC.Mail.Resources.MailScriptResource.NotSpamLabel}</span>
                </li>
                {{/if}}
                {{/if}}
                <li class="menuAction btnMoveTo unlockAction">
                    <span title="${ASC.Mail.Resources.MailResource.MoveTo}">${ASC.Mail.Resources.MailResource.MoveTo}</span>
                    <div class="down_arrow"></div>
                </li>
                <li class="menuAction btnMore unlockAction">
                    <span title="${ASC.Mail.Resources.MailResource.MoreMenuButton}">...</span>
                </li>
                <li class="menuAction btnNext unlockAction pull-right" title="${ASC.Mail.Resources.MailResource.GoToNextMessage}">
                    <div class="arrow-right"></div>
                </li>
                <li class="menuAction btnPrev unlockAction pull-right" title="${ASC.Mail.Resources.MailResource.GoToPrevMessage}">
                    <div class="arrow-left"></div>
                 </li>                
                {{if typeof($item.needSortButton)!=='undefined' && $item.needSortButton}}
                <li class="menu-action-simple-pagenav" style="display: list-item;">
                    <span id="sort-conversation" class="sort-icon hidden-min"></span>
                    <span id="collapse-conversation" class="collapse-conversation hidden-min"><%: MailScriptResource.ExpandAllLabel %></span>
                </li>
                {{/if}}
                <li class="menu-action-on-top">
                    <a class="on-top-link" onclick="javascript:window.scrollTo(0, 0);">
                        ${ASC.Mail.Resources.MailResource.OnTopLabel}
                    </a>
                </li>
            </ul>
            <div class="header-menu-spacer">&nbsp;</div>
        </div>
    </div>
</script>

<script id="imagesBlockedPopupTmpl" type="text/x-jquery-tmpl">
    <div>
        <div>
            ${text}
        </div>
        <div class="buttons">
            <button class="button middle blue okBtn" type="button">
                ${ASC.Mail.Resources.MailScriptResource.OkBtnLabel}</button>
            <button class="button middle gray cancel" type="button">
                ${ASC.Mail.Resources.MailScriptResource.CancelBtnLabel}
            </button>
        </div>
    </div>
</script>